#include <QFile>
#include <QString>
#include <QtGui/QApplication>
#include <QtWebKit/QWebView>
#include <QtWebKit/QWebFrame>
#include <QUrl>

#include "com/SocketServer.h"
#include "com/SocketClient.h"
#include "core/Core.h"
#include "item/Aircraft.h"

using namespace br::org::core;
using namespace br::org::item;

int main( int argc, char *argv[] )
{
    QApplication app( argc, argv );

    QString hostServer( app.arguments().at( 1 ) );
    qint16 portServer = QString( app.arguments().at( 2 ) ).toInt();
    QString hostClient( app.arguments().at( 3 ) );
    qint16 portClient = QString( app.arguments().at( 4 ) ).toInt();

    CorePtr core( Core::get() );

    core->startCom( QHostAddress( hostServer ), portServer, QHostAddress( hostClient ), portClient );

    Aircraft* p1 = new Aircraft();
    p1->setId( 1 );
    core->add( p1 );

    Aircraft* p2 = new Aircraft();
    p2->setId( 2 );
    p2->setX( 100 );
    core->add( p2 );

    core->showView();

    return app.exec();
}





//#include "ReportPage.h"

//    QWidget* parent = new QWidget();
//    QWebView *view = new QWebView(parent);

//    view->load(QUrl("qrc:///img/index.html"));
//    view->show();
//    parent->show();

//    QFile file;
//    file.setFileName( ":/img/jquery-1.5.2.min.js" );
//    file.open( QIODevice::ReadOnly );
//    QString jQuery = file.readAll();
//    file.close();


//    file.setFileName( ":/img/jquery.charts.js" );
//    file.open( QIODevice::ReadOnly );
//    QString jQueryCharts = file.readAll();
//    file.close();



//    view->page()->mainFrame()->evaluateJavaScript( jQuery );
//    view->page()->mainFrame()->evaluateJavaScript( jQueryCharts );

//    view->page()->mainFrame()->evaluateJavaScript( "$(document).ready(function(){ alert(\"Thanks for visiting!\") })" );
//    view->page()->mainFrame()->evaluateJavaScript( "$(\"#example\").charts();" );
